package com.mj.factory.productOrder;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class ProductOrderService {
    @Autowired
    ProductOrderDao productOrderDao;

    Page<ProductOrder> findAll(Pageable pageable) {
        return productOrderDao.findAll(pageable);
    }

    List<ProductOrder> findAll() {
        return productOrderDao.findAll();
    }

    public ProductOrder findByProjectNumber(String projectNumber) {
        return productOrderDao.findByProjectNumber(projectNumber);
    }

    public boolean delete(List<ProductOrder> list) {
        boolean flag = false;
        try {
            productOrderDao.deleteInBatch(list);
            flag = true;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return flag;
    }

    public ProductOrder findById(long id) {
        return productOrderDao.findOne(id);
    }

    public void save(ProductOrder technologicalProcess) {
        productOrderDao.save(technologicalProcess);
    }

}
